home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / tsocks.distrib < prev    next >
Encoding:
Text File  |  2008-06-08  |  2.2 KB  |  90 lines

  1. #!/bin/sh
  2. # Wrapper script for use of the tsocks(8) transparent socksification library
  3. #
  4. # There are three forms of usage for this script:
  5. #
  6. # /usr/bin/tsocks program [program arguments...]
  7. #
  8. # This form sets the users LD_PRELOAD environment variable so that tsocks(8) 
  9. # will be loaded to socksify the application then executes the specified 
  10. # program (with the provided arguments). The following simple example might 
  11. # be used to telnet to www.foo.org via a tsocks.conf(5) configured socks server:
  12. #
  13. # /usr/bin/tsocks telnet www.foo.org
  14. #
  15. # The second form allows for tsocks(8) to be switched on and off for a 
  16. # session (that is, it adds and removes tsocks from the LD_PRELOAD environment
  17. # variable). This form must be _sourced_ into the user's existing session
  18. # (and will only work with bourne shell users):
  19. #
  20. # . /usr/bin/tsocks on
  21. # telnet www.foo.org 
  22. # . /usr/bin/tsocks off
  23. # Or
  24. # source /usr/bin/tsocks on
  25. # telnet www.foo.org
  26. # source /usr/bin/tsocks off
  27. #
  28. # The third form creates a new shell with LD_PRELOAD set and is achieved
  29. # simply by running the script with no arguments 
  30. # /usr/bin/tsocks
  31. #
  32. # When finished the user can simply terminate the shell with 'exit'
  33. # This script is originally from the debian tsocks package by 
  34. # Tamas Szerb <toma@rulez.org>
  35.  
  36. #if [ $# = 0 ] ; then
  37. #   echo "$0: insufficient arguments"
  38. #   exit
  39. #fi
  40.  
  41. case "$1" in
  42.     -on)
  43.         if [ -z "$LD_PRELOAD" ]
  44.             then
  45.                 export LD_PRELOAD="/usr/lib/libtsocks.so"
  46.             else
  47.                 echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \
  48.                 export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"
  49.         fi
  50.     ;;
  51.     -off)
  52.         export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/usr\/lib\/libtsocks.so \?//'`
  53.         if [ -z "$LD_PRELOAD" ]
  54.             then
  55.                 unset LD_PRELOAD
  56.         fi
  57.     ;;
  58.     -show|-sh)
  59.         echo "LD_PRELOAD=\"$LD_PRELOAD\""
  60.     ;;
  61.     -h|-?)
  62.       echo "$0: Please see tsocks(1) or read comment at top of $0"
  63.    ;;
  64.     *)
  65.         if [ -z "$LD_PRELOAD" ]
  66.         then
  67.             export LD_PRELOAD="/usr/lib/libtsocks.so"
  68.         else
  69.             echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \
  70.             export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"
  71.         fi
  72.  
  73.         if [ $# = 0 ]
  74.         then
  75.             ${SHELL:-/bin/sh}
  76.         fi
  77.  
  78.         if [ $# -gt 0 ]
  79.         then
  80.             exec "$@"
  81.         fi
  82.     ;;
  83. esac
  84.  
  85. #EOF
  86.